package com.pureland.security.feign;

import com.pureland.security.feign.interceptor.HeaderFeignClientInterceptor;
import feign.Feign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2ClientContext;

/**
 * @projectName: pureland_cloud
 * @className: com.pureland.security.HeaderFeignConfiguration
 * @description: Feign请求头配置
 * @author: tong.li
 * @createTime: 2020/11/17 17:13
 * @version: v1.0
 * @copyright: 版权所有 李彤 © 2020
 */
@Slf4j
@Configuration
@ConditionalOnClass(Feign.class)
@Import(HeaderFeignClientInterceptor.class)
public class HeaderFeignConfiguration {

    @Primary
    @Bean
    public OAuth2ClientContext oAuth2ClientContext() {
        return new DefaultOAuth2ClientContext();
    }
}
